Skip to content

crypto: unify asymmetric key import through KeyObjectHandle::Init#62499

Open
panva wants to merge 2 commits intonodejs:mainfrom
panva:key-refactor
Open

crypto: unify asymmetric key import through KeyObjectHandle::Init#62499
panva wants to merge 2 commits intonodejs:mainfrom
panva:key-refactor

Conversation

@panva
Copy link
Copy Markdown
Member

@panva panva commented Mar 29, 2026

Note

will rebase after #62480, review bdfec98, it's what this will be

Consolidate all asymmetric key import paths (DER/PEM, JWK, raw) into a single KeyObjectHandle::Init() entry point with a uniform signature.

Remove the per-type C++ init methods (InitECRaw, InitEDRaw, InitPqcRaw, InitJwk, InitECPrivateRaw) and their JS-side callers, replacing them with shared C++ and JS helpers.

createPublicKey, createPrivateKey, sign, verify, and other operations that accept key material now handle JWK and raw formats directly in C++, removing redundant JS-to-C++ key handle round-trips.

panva added 2 commits March 29, 2026 21:41
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Consolidate all asymmetric key import paths (DER/PEM, JWK, raw) into
a single KeyObjectHandle::Init() entry point with a uniform signature.

Remove the per-type C++ init methods (InitECRaw, InitEDRaw, InitPqcRaw,
InitJwk, InitECPrivateRaw) and their JS-side callers, replacing them
with shared C++ and JS helpers.

createPublicKey, createPrivateKey, sign, verify, and other operations
that accept key material now handle JWK and raw formats directly in
C++, removing redundant JS-to-C++ key handle round-trips.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva added crypto Issues and PRs related to the crypto subsystem. webcrypto dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. labels Mar 29, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 29, 2026
@panva panva marked this pull request as ready for review March 29, 2026 21:29
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 86.24484% with 100 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.70%. Comparing base (f3633ef) to head (bdfec98).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_keys.cc 75.32% 31 Missing and 44 partials ⚠️
src/crypto/crypto_ec.cc 81.81% 3 Missing and 7 partials ⚠️
lib/internal/crypto/keys.js 89.70% 6 Missing and 1 partial ⚠️
src/crypto/crypto_ml_dsa.cc 88.67% 1 Missing and 5 partials ⚠️
lib/internal/crypto/webcrypto_util.js 98.92% 0 Missing and 1 partial ⚠️
src/crypto/crypto_rsa.cc 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62499      +/-   ##
==========================================
- Coverage   91.54%   89.70%   -1.84%     
==========================================
  Files         351      693     +342     
  Lines      147704   213849   +66145     
  Branches    23214    40959   +17745     
==========================================
+ Hits       135214   191841   +56627     
- Misses      12235    14061    +1826     
- Partials      255     7947    +7692     
Files with missing lines Coverage Δ
lib/internal/crypto/aes.js 89.89% <100.00%> (+1.43%) ⬆️
lib/internal/crypto/cfrg.js 93.23% <100.00%> (-1.24%) ⬇️
lib/internal/crypto/chacha20_poly1305.js 92.05% <100.00%> (-0.72%) ⬇️
lib/internal/crypto/cipher.js 97.94% <100.00%> (ø)
lib/internal/crypto/ec.js 94.17% <100.00%> (-0.61%) ⬇️
lib/internal/crypto/kem.js 97.41% <100.00%> (+0.09%) ⬆️
lib/internal/crypto/mac.js 92.70% <100.00%> (+1.57%) ⬆️
lib/internal/crypto/ml_dsa.js 95.39% <100.00%> (+0.35%) ⬆️
lib/internal/crypto/ml_kem.js 92.45% <100.00%> (+0.56%) ⬆️
lib/internal/crypto/rsa.js 94.51% <100.00%> (+2.10%) ⬆️
... and 11 more

... and 455 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crypto Issues and PRs related to the crypto subsystem. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. webcrypto

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants